//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: ICacheManager.cs
//
//  Description: Offers methods for a caching mechanism.
// 
//--------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Chili.Opf3.Query;

namespace Chili.Opf3.Caching
{
	/// <summary>
	/// Interface implemented by classes that provide a caching algorithm for persistent objects.
	/// </summary>
	/// <remarks>
	/// This interface is implemented by classes that provide a caching algorithm for persistent objects.
	/// The cache holds instance of loaded persistence objects until they expire. On a load operation the 
	/// cache is queried to see if it holds still an instance of a persistent object that is due to load.
	/// </remarks>
	public interface ICacheManager
	{
		/// <summary>
		/// Gets an instance of the <see cref="ObjectReader{T}">ObjectReader</see> for the given query.
		/// </summary>
		/// <param name="context">The <see cref="ObjectContext">ObjectContext</see> used to load the reader.</param>
		/// <param name="query">A class that implements the <see cref="IQuery">IQuery</see> interface.</param>
		ObjectReader<T> GetObjectReader<T>(ObjectContext context, IQuery query);

		/// <summary>
		/// Adds a persistent object to the cache.
		/// </summary>
		/// <param name="obj">The object that is added.</param>
		bool AddPersistentObject(object obj);
	}
}
